﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Gollie.Extensions
{
	public static class StringExtensions
	{
		/// <summary>
		/// Cleans up all control chars
		/// </summary>
		/// <param name="str"></param>
		/// <returns></returns>
		public static string Clean(this string str)
		{
			return new string((str.Where(c => c.CompareTo(' ') >= 0)).ToArray());
		}

		public static bool IsHex(this string str)
		{
			foreach (char c in str)
			{
				if (!(char.IsDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))
					return false;
			}

			return true;
		}

		public static string SingleQuote(this string str)
		{
			return "\'" + str + "\'";
		}
	}
}